<template>
{{#if ctrl.psSysPFPlugin}}
    {{> @macro/plugins/widget/widget-use.hbs appPlugin=ctrl.psSysPFPlugin}}
{{else}}
  <div :class="classNames" :id="controlID" style="{{#if ctrl.width}}width: {{ctrl.width}}px;{{/if}}{{#if ctrl.height}}height: {{ctrl.height}}px;{{/if}}min-height:200px;">
    <AppEmptyDataTip v-if="store.isNoData" {{#or ctrl.emptyTextPSLanguageRes ctrl.emptyText}}:emptyText="{{#if ctrl.emptyTextPSLanguageRes}}$t('{{ctrl.emptyTextPSLanguageRes.lanResTag}}', '{{ctrl.emptyText}}'){{else}}{{ctrl.emptyText}}{{/if}}"{{/or}}></AppEmptyDataTip>
    <div v-else class="control-content app-control-chart__content" :id="store.chartId"></div>
  </div>
{{/if}}
</template>
<script setup lang="ts">
// 基于template/src/widgets/\{{appEntities}}/\{{ctrls@CHART}}-chart/\{{spinalCase ctrl.codeName}}-chart.vue.hbs生成
{{> @macro/plugins/widget/widget-import.hbs ctrl=ctrl}}
import { model } from "./{{spinalCase ctrl.codeName}}-chart-model";
import { {{pascalCase ctrl.name}}ControlVO } from './{{spinalCase ctrl.codeName}}-chart-vo';
import { IContext, IParam, createUUID, ILoadingHelper, ChartActionType, ICtrlDataAction, IChartAbility, IChartController, IChartControllerParams, IChartStore, ChartController, IViewCtx } from "@/core";
import { useNavParamsBind, useEventBind, getCtrlClassNames } from '@/hooks/use-ctrl';
import ChartService from "@/core/modules/ctrl-service/chart-service";

// 输入参数
{{> @macro/widgets/ctrl/ctrl-props.hbs
    props="openView?: Function;
    newView?: Function;
    actions: ICtrlDataAction;    
    selectFirstDefault?: boolean;
    "
}}

// emit
{{> @macro/common/emit.hbs name="ctrl" actionType="ChartActionType" ability="IChartAbility"}}

//  部件样式名
const classNames = computed(() => {
    return getCtrlClassNames(model, props);
});

const controlID = 'id' + createUUID();     

// 部件服务
const ctrlService = new ChartService<{{pascalCase ctrl.name}}ControlVO>({{pascalCase ctrl.name}}ControlVO, model.entityCodeName)

const params: IChartControllerParams<ChartActionType, IChartAbility> = {
    name: props.name,    
    model,
    evt,
    controlID,    
    pLoadingHelper: props.pLoadingHelper,      
    actions: props.actions,
    openView: props.openView,
    newView: props.newView,
    closeView: props.closeView,
    selectFirstDefault: props.selectFirstDefault,
    ctrlService: ctrlService,
    pViewCtx: props.pViewCtx,
    handler: (data: IChartStore) => { return reactive(data); }
};

{{> @macro/common/controller.hbs name="ctrl" IController="IChartController" store="IChartStore" ability="IChartAbility" controller="ChartController"}}
</script>